package com.citasgoo.aliyunFacility.util;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.IOException;

public class Base64JDK {

    public static  String encode(String source){
        BASE64Encoder encoder = new BASE64Encoder();
        String data = encoder.encode(source.getBytes());
        return data;
    }


    public static  String decode(String source) {
        try {
            BASE64Decoder decoder = new BASE64Decoder();
            byte[] bytes = decoder.decodeBuffer(source);
            return new String(bytes);
        }catch (IOException e){
            return "";
        }
    }

    public static void main(String[] args) {
        System.out.println(encode("EazVkMgSpkMgqT7Xn9BExs0eldBiKW"));
    }
}
